package com.itcast.demo.controller;

import com.itcast.demo.pojo.Employee;
import com.itcast.demo.pojo.TestEnum;
import com.itcast.demo.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/emp")
public class EmployeeController {

    @Autowired
    private EmployeeService employeeService;

    @PostMapping("/insertAndUpdate")
    public void insertAndUpdate(@RequestBody Employee employee) {
        employeeService.insertAndUpdate(employee);
    }

    // 测试枚举参数
    @PostMapping("/testEnum")
    public void testEnum(@RequestBody TestEnum testEnum) {
        employeeService.save(testEnum);
    }
    @PostMapping("/testEnum2")
    public void testEnum2(@RequestBody TestEnum testEnum) {
        TestEnum testEnum1 = employeeService.getById(testEnum.getUserId());
        System.out.println(testEnum1);
    }

}
